<?php
    include 'base.php';

    $username = $_POST['username'];
    $password = $_POST['password'];
    //连接 数据表user
    $sql = "SELECT * FROM `user` WHERE `username`='$username' AND `password`='$password'";

    $res = $conn->query($sql);
      
    //        拿出一条数据 
    $row = mysqli_fetch_assoc($res);

    if ($row) {
        echo json_encode(array(
            "msg" => '登陆成功',
            "state" => 200,
            "code" => true     // 没有错误
        ));
    } else {
        echo json_encode(array(
            "msg" => '用户名或者密码错误',
            "state" => 200,
            "code" => false     // 有一个错误
        ));
    }
?>